<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array('add', 'refresh'))); ?></div>

<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<div class="fail-flash">
    No record found.
</div>
<? else : // ถ้ามีข้อมูล ?>
    <?php echo $this->element('pageHeader'); ?>
    <?php $cur = $paginator->counter(array('format' => '%start%')); ?>
<table class="data">
    <thead>
        <tr>
            <th width="100px"><?php echo $paginator->sort('Customer No'); ?></th>
            <th><?php echo $paginator->sort('Short Name', 'Short Name'); ?></th>
            <th><?php echo $paginator->sort('Name'); ?></th>
            <th><?php echo $paginator->sort('Collect Date'); ?></th>
            <th class="collector"><?php echo $paginator->sort('Collector', 'User.name'); ?></th>
            <th width="50px">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
            <?php foreach($this->data as $data): ?>
                <?php
                $tableCell = array();
                $cur++;
                $tableCell[] = $data['Customer']['cust_no'];
                $tableCell[] = $html->tag('span', $data['Customer']['short_name']);
                $tableCell[] = $html->tag('span', $data['Customer']['name'], array('id' => "name$cur"));
                $tableCell[] = $html->tag('span', $data['Customer']['modified'], array('class' => 'lower'));
                $tableCell[] = $data['User']['name'];
                $tableCell[] = (in_array($data['Customer']['id'], $customerOnHands)?
                        $ajax->link($html->image('icon/edit.png', array('title' => 'edit', 'alt' => 'edit')),
                        'view/' . $data['Customer']['id'] . '/' . time(),
                        array('indicator' => 'indicator', 'update' => 'content'), null, false) . '&nbsp;' .
                                $html->link($html->image('icon/cust_head_user_icon.png'), array('controller' => 'its_admins', 'action' => 'view_as_customer_user', $data['Customer']['id']), array('id' => 'viewAsCustomer' . $cur, 'title' => 'View as Customer user'), null, false) .
                                $this->element('javascript/confirm_link', array('id' => 'viewAsCustomer' . $cur, 'message' => "Do you want to view as \"{$data['Customer']['name']}\" user?")): '');
                echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                ?>
            <?php endforeach; ?>
    </tbody>
</table>
    
    <?php echo $this->element('paging'); ?>
<? endif; ?>